$("#txtStartTime").bind("click focus", function () {             
   var endtimeTf = $dp.$('txtEndTime');             
   WdatePicker({                            
	   maxDate: '#F{$dp.$D(\'txtStartTime\')}',      
	   dateFmt: "yyyy-MM-dd HH:mm:ss",              
	   onpicked: function () { endtimeTf.focus(); }          
		});         
   });          
   $("#txtEndTime").bind("click focus", function () {       
		WdatePicker({           
		   minDate: '#F{$dp.$D(\'txtStartTime\')}', 
		   dateFmt: "yyyy-MM-dd HH:mm:ss"       
	   });         
   });
//选择隐藏
    $("#dropmsg_a").hide();
	$("#dropmsg_c").hide(); 	
	$("#dropmsg").show(); 
	function change(){ 
		if($("#goods_style").attr("value")=='1'){ 
			$("#dropmsg_a").show(); 
			$("#dropmsg").hide(); 
			$("#dropmsg_c").hide(); 
		}else{ 
			if($("#goods_style").attr("value")=='2'){ 
				$("#dropmsg_c").show(); 
			}
			else{
			 $("#dropmsg_c").hide(); 
			}
			$("#dropmsg_a").hide(); 
			$("#dropmsg").show(); 
		} 
	} 

 $("#submitImgUploadBtn").on("click",function(e){
        //var active = $("#imgDialog-tabNavCon").children(".active");
        ImgUpload.upload();
    })
    $("#imgUpload_inpFile").on("change",function(e){
        ImgUpload.onFileChange(e.currentTarget);
    })
    var ImgUpload = (function(){

        function onFileChange(inpFile){
            var path = inpFile.value;
            path = path.replace(/c:\\fakepath\\/gi,"");
            path.replace(/c:/ig,"");
            $("#imgUpload_fileVal").val(path);
        }
        function upload(){
            // $("#image-container").hide();
            onloading();
            $("#imgUpload_form").submit();
        }
        function onloading(){
            var imgname = $("#imgUpload_fileVal").val();
            var loadingImg = "http://www.12301.cc/images/other/loading_1.gif";
            var html = '<div class="uploadResult loading"><div class="con"><img src="'+loadingImg+'"/><span class="text">正在上传图片...</span></div></div>';
            $("#uploadFailTip").hide();
            $("#uploadResultCon").html(html);
        }
        function onload(data){ //上传图片完成
            console && console.log("上传图片完成，未知是否成功");
            if(data.status == "ok" && data.key){
                console && console.log("上传图片成功");
                onSuccess(data);
            }else{
                console && console.log("上传图片失败");
                onFail(data)
            }
        }
        function onSuccess(data){
            var path = data.key;
            //var html = '<div class="ui-form-item"><div class="lnk_prv"><img src="'+path+'"/></div></div>';
            //$("#uploadResultCon").html(html);
			$("#discount_img").attr('src',path);
            $("#showimgPathInp").val(path);
			$("#uploadResultCon").hide();
            WXB.G.Alert("success",'<p style="width:150px;">上传图片成功</p>',2000)
        }
        function onFail(data){
            var img = '<img src="http://www.12301.cc/wx_public/images/nopic.jpg"  class="img-responsive img-thumbnail" width="150">';
            $("#uploadResultCon").html(img);
            $("#uploadFailTip").show();
            WXB.G.Alert("fail",'<p style="width:150px;">上传图片失败</p>')
        }
        return{
            onFileChange : onFileChange,
            upload : upload,
            onload : onload
        }

    })();